home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / MPW Goodies / MPW Goodies⁄DTS / CancelWindowCheckOut < prev    next >
Text File  |  2022-08-05  |  2KB  |  71 lines

  1. #    CancelWindowCheckOut - revert to an old copy of a checked-out window
  2. #
  3. #    Usage:    CancelWindowCheckOut window
  4. #
  5. #    Status:    CancelWindowCheckOut may return the following status values:
  6. #
  7. #            0        the window was reverted
  8. #            1        error
  9. #            4        the user canceled
  10. #
  11. #    CancelWindowCheckOut cancels the changes that have been made
  12. #    to a file in a window.
  13. #
  14. #    © 1988, 1989 Apple Computer, Inc.
  15. #    All rights reserved.
  16.  
  17. Set Exit 0
  18. Set CaseSensitive 0
  19.  
  20. # the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
  21. If {Echo} == 1
  22.     Set somewhere "∑∑ '{Worksheet}∂'"
  23. Else
  24.     Set somewhere '∑ Dev:Null'
  25. End
  26.  
  27. Begin
  28.  
  29.     Set Window "{1}"
  30.  
  31.     # get short name of window
  32.  
  33.     If "{Window}" !~ /:*([¬:]+:*)*([¬:]+)®1/
  34.         Exit 1
  35.     End
  36.     Set Short "{®1}"                    # get short name for dialogs
  37.     Set Cant "Changes to “{Short}” can’t be discarded"
  38.  
  39.     # check what project the window belongs to
  40.  
  41.     Set Info "`ProjectInfo "{Window}"`"
  42. ###    If "{Info}" !~ /≈Project: (≈∫)®1 ≈/
  43.     If "{Info}" !~ /≈Project: (≈)®1     Checked out: ≈/
  44.         Alert "{Cant} because it doesn’t belong to a project."
  45.         Exit 1
  46.     End
  47.     Set Project "{®1}"
  48.  
  49.     # ensure that the window is checked out
  50.  
  51.     If "{Info}" !~ /[¬,]+,[¬ ∂t]+∂+≈/
  52.         Alert "{Cant} because it wasn’t checked out."
  53.         Exit 1
  54.     End
  55.  
  56.     # check if the project is mounted
  57.  
  58.     Set Info "`ProjectInfo -only -project "{Project}"; Set InfoStatus {Status}`"
  59.     If {InfoStatus} != 0
  60.         Alert "{Cant} because the project “{Project}” is not mounted."
  61.         Exit 1
  62.     End
  63.  
  64.     # *** what about a way to start over (get a new modifiable)?
  65.     # *** in that case, what about introducing a new branch?
  66.     CheckOut -project "{Project}" -cancel "{Window}"
  67.     Set CheckOutStatus {Status}
  68.     Exit {CheckOutStatus}
  69.  
  70. End {somewhere}
  71.